package com.ruoyi.factory.staffSafe.controller;


import com.ruoyi.factory.staffSafe.service.IYunXuetangService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;


/**
 * @ClassName YunXuetang
 * @Description: TODO 云学堂openapi 已废弃 集成到staffsafe
 * @Author LiuJiaji
 * @Date 2024/4/9 14:55
 **/
@RestController
@RequestMapping("/api/yunXuetang")
public class YunXuetangController {

    @Autowired
    public IYunXuetangService yunXuetangService;

//    @Scheduled(cron="0 3 1 * * ?")
//    public void getstudyrecord(){
//        yunXuetangService.getstudyrecord();
//    }
//
//    //每天执行
//    @PostMapping("/getyxtstaffinfo")
//    public void getyxtstaffinfo(){
//        //每天同步一次信息
//        yunXuetangService.getyxtstaffinfo();
//    }

//    public static void main(String[] args) {
//        List<StaffsafeInfo> list = new ArrayList<>();
//        StaffsafeInfo p1 = new StaffsafeInfo();
//        p1.setId("1111");
//        StaffsafeInfo p2 = new StaffsafeInfo();
//        p2.setId("2222");
//        StaffsafeInfo p3 = new StaffsafeInfo();
//        p3.setId("3333");
//        list.add(p1);
//        list.add(p2);
//        list.add(p3);
//        for (StaffsafeInfo staffsafeInfo : list) {
//            String id = staffsafeInfo.getId();
//            if("2222".equals(id)){
//                staffsafeInfo.setId("999999");
//            }
//        }
//        for (StaffsafeInfo staffsafeInfo : list) {
//            System.out.println(staffsafeInfo.getId());
//        }
//    }

//    public static void main(String[] args) {
//        // 对应平台的 appId与appSecret
//        String appId = "axrvn4iokfl";
//        String appSecret = "NjA4MjlmZWM5MzAz";
//
//        Map<String, Object> body = new HashMap<>();
//
//        // 请求接口地址
//        String url = "https://openapi.yunxuetang.cn/token";
//        // url拼接所需参数
//        String pathUrl = url + "?" + "appId=" + appId + "&appSecret=" + appSecret;
//        // 以post方式调用第三方接口,获取响应结果
////        String result = HttpClientUtil.doPost(pathUrl, body, null);
//        JSONObject jsonObject = JSONObject.fromObject(body);
//        String s = OkHttpUtils.okHttpPost(pathUrl, jsonObject.toString());
//        System.out.println(s);
//
//        // 返回accessToken
////        JSONObject jsonObject = JSON.parseObject(result, JSONObject.class);
////        String res =  jsonObject.getString("accessToken");
//    }
    public static void main(String[] args) {
        for (int i = 0; i <6 ; i++) {
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
            Map<String, Object> body = new HashMap<>();
            Calendar instance = Calendar.getInstance();
            int xi = instance.get(Calendar.YEAR);
            instance.add(Calendar.MONTH,-i);
            int xi1 = instance.get(Calendar.MONTH)+1;
            instance.add(Calendar.MONTH,-1);
            int xi3 = instance.get(Calendar.MONTH)+1;
            String xeformat = String.format("%02d", xi1);
            String xsformat = String.format("%02d", xi3);
            int xi2 = instance.get(Calendar.DATE);
            instance.set(Calendar.DAY_OF_MONTH,1);
            Date time = instance.getTime();
            String format = sdf.format(time);
            instance.add(Calendar.MONTH,1);
            instance.add(Calendar.DATE,-15);

            Date time1 = instance.getTime();
            String format1 = sdf.format(time1);
            instance.add(Calendar.DATE,1);

            Date time3 = instance.getTime();
            String format3 = sdf.format(time3);
            instance.add(Calendar.DATE,13);
            Date time2 = instance.getTime();
            String format2 = sdf.format(time2);
            System.out.println("开始时间"+format+" 00:00:00");
            System.out.println("结束时间"+format1+" 23:59:59");
            System.out.println("开始时间"+format3+" 00:00:00");
            System.out.println("结束时间"+format2+" 23:59:59");

        }

    }

//    public static void main(String[] args) {
//        String ss = "王凌云(创建人)";
//        String[] split = ss.split("\\(");
//        System.out.println(split[0]);
//    }



}
